<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE"/>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title>Teamwork</title>

  <link rel=stylesheet href="platform.css" type="text/css">
  <link rel=stylesheet href="libs/dateField/jquery.dateField.css" type="text/css">
  <link rel=stylesheet href="gantt.css" type="text/css">

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

  <script src="libs/jquery.livequery.min.js"></script>
  <script src="libs/jquery.timers.js"></script>
  <script src="libs/platform.js"></script>
  <script src="libs/date.js"></script>
  <script src="libs/i18nJs.js"></script>
  <script src="libs/dateField/jquery.dateField.js"></script>
  <script src="libs/JST/jquery.JST.js"></script>

  <script src="ganttUtilities.js"></script>
  <script src="ganttTask.js"></script>
  <script src="ganttDrawer.js"></script>
  <script src="ganttGridEditor.js"></script>
  <script src="ganttMaster.js"></script>

</head>
<body style="background-color: #fff;">


<div id="workSpace" style="padding:0px; overflow-y:auto; overflow-x:hidden;border:1px solid #e5e5e5;position:relative;margin:0 5px"></div>

<div id="taZone" style="display:;">
  <textarea rows="8" cols="150" id="ta">
  	{"selectedRow":6,"resources":[{"id":"tmp_1","name":"Resource 1"},{"id":"tmp_2","name":"Resource 2"},{"id":"tmp_3","name":"Resource 3"},{"id":"tmp_4","name":"Resource 4"},{"id":"tmp_5","name":"Resource 5"},{"id":"tmp_6","name":"Resource 6"},{"id":"tmp_7","name":"Resource 7"},{"id":"tmp_8","name":"Resource 8"},{"id":"tmp_9","name":"Resource 9"},{"id":"tmp_10","name":"Resource 10"}],"canWrite":true,"deletedTaskIds":[],"roles":[{"id":"tmp_1","name":"Project Manager"},{"id":"tmp_2","name":"Worker"},{"id":"tmp_3","name":"Stakeholder/Customer"}],"tasks":[{"startIsMilestone":true,"workplanRelated":"","progress":"","status":"STATUS_ACTIVE","resourceDesc":"","assessDesc":"","resource":"","code":"13617186010451921347","endIsMilestone":false,"id":-1,"duration":57,"level":0,"start":1361721600000,"name":"智慧旅游平台开发","assigs":[],"assess":"","depends":"","end":1368547199999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_ACTIVE","resourceDesc":"","assessDesc":"","resource":"","code":"13617186821068969857","endIsMilestone":false,"id":"tmp_fk1361718679572","duration":1,"level":1,"start":1361721600000,"name":"需求调研分析阶段","assigs":[],"assess":"","depends":"","end":1361807999999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_ACTIVE","resourceDesc":"","resource":"","assessDesc":"","code":"13617187758471712789","endIsMilestone":false,"id":"tmp_fk1361718742455","duration":1,"level":2,"start":1361721600000,"name":"业务调研","assigs":[],"assess":"","depends":"","end":1361807999999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_ACTIVE","resourceDesc":"","resource":"","assessDesc":"","code":"13617187758507809055","endIsMilestone":false,"id":"tmp_fk1361718761568","duration":1,"level":2,"start":1361721600000,"name":"需求确认(demo，功能列表，问题票)","assigs":[],"assess":"","depends":"","end":1361807999999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_ACTIVE","resourceDesc":"","assessDesc":"","resource":"","code":"13617188607773604426","endIsMilestone":false,"id":"tmp_fk1361718832168","duration":2,"level":1,"start":1361894400000,"name":"系统设计阶段","assigs":[],"assess":"","depends":"","end":1362067199999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_ACTIVE","resourceDesc":"","assessDesc":"","resource":"","code":"13617188607812012838","endIsMilestone":false,"id":"tmp_fk1361718851908","duration":2,"level":2,"start":1361894400000,"name":"系统设计及设计说明书评审","assigs":[],"assess":"","depends":"","end":1362067199999},

{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"范钢锋","resource":"","assessDesc":"无","code":"13617189816021392687","endIsMilestone":false,"id":"tmp_fk1361718875258","duration":32,"level":1,"start":1362067200000,"description":"","name":"软件开发阶段","assigs":[],"assess":"0","depends":"6","end":1366041599999},


    {"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","resource":"","assessDesc":"","code":"13617189816151198902","endIsMilestone":false,"id":"tmp_fk1361718940009","duration":30,"level":2,"start":1362067200000,"name":"搭建网站群系统","assigs":[],"assess":"","depends":"","end":1365695999999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","assessDesc":"","resource":"","code":"13617191035965070355","endIsMilestone":false,"id":"tmp_1361719052153","duration":8,"level":3,"start":1362067200000,"name":"界面设计","assigs":[],"assess":"","depends":"","end":1363103999999},
    {"startIsMilestone":false,"workplanRelated":"","progress":0,"status":"STATUS_SUSPENDED","resourceDesc":"范钢锋","assessDesc":"无","resource":"bluewind","code":"13617191035991139309","endIsMilestone":false,"id":"tmp_1361719065656","duration":10,"level":3,"start":1363104000000,"description":"","name":"栏目制作（GIS、二维码等的介绍、链接）","assigs":[],"assess":"0","depends":"9","end":1364313599999},{"startIsMilestone":false,"workplanRelated":"","progress":0,"status":"STATUS_SUSPENDED","resourceDesc":"范钢锋","assessDesc":"无","resource":"bluewind","code":"13617195223521466002","endIsMilestone":false,"id":"tmp_1361719515040","duration":10,"level":3,"start":1363104000000,"description":"","name":"智慧旅游行业建设解决方案","assigs":[],"assess":"0","depends":"9","end":1364313599999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","resource":"","assessDesc":"","code":"13617639980942180079","endIsMilestone":false,"id":"tmp_1361763976671","duration":10,"level":3,"start":1363104000000,"name":"招标信息发布平台","assigs":[],"assess":"","depends":"","end":1364313599999},
    {"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","resource":"","assessDesc":"","code":"13617189816181693874","endIsMilestone":false,"id":"tmp_fk1361718956830","duration":31,"level":2,"start":1362067200000,"name":"搭建SAAS平台","assigs":[],"assess":"","depends":"","end":1365782399999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","resource":"","assessDesc":"","code":"13617191553312748423","endIsMilestone":false,"id":"tmp_fk1361719138922","duration":3,"level":3,"start":1362067200000,"name":"云资源在线申请、渲染服务申请","assigs":[],"assess":"","depends":"","end":1362499199999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","resource":"","assessDesc":"","code":"13617194709371574013","endIsMilestone":false,"id":"tmp_fk1361719421651","duration":30,"level":3,"start":1362067200000,"name":"旅游管理部门服务平台","assigs":[],"assess":"","depends":"","end":1365695999999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","assessDesc":"","resource":"","code":"13617199491535135696","endIsMilestone":false,"id":"tmp_1361719925077","duration":30,"level":4,"start":1362067200000,"name":"旅游企业信息管理系统OA","assigs":[],"assess":"","depends":"","end":1365695999999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","resource":"","assessDesc":"","code":"13617194709407437361","endIsMilestone":false,"id":"tmp_fk1361719432351","duration":15,"level":3,"start":1362067200000,"name":"旅游企业服务平台","assigs":[],"assess":"","depends":"","end":1363881599999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","assessDesc":"","resource":"","code":"13617199491621904162","endIsMilestone":false,"id":"tmp_1361719903153","duration":15,"level":4,"start":1362067200000,"name":"企业宣传展示系统","assigs":[],"assess":"","depends":"","end":1363881599999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","resource":"","assessDesc":"","code":"13617197269382018925","endIsMilestone":false,"id":"tmp_fk1361719669378","duration":8,"level":3,"start":1362067200000,"name":"产业联盟","assigs":[],"assess":"","depends":"","end":1363103999999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_SUSPENDED","resourceDesc":"","assessDesc":"","resource":"","code":"13617623497142763272","endIsMilestone":false,"id":"tmp_1361762146071","duration":1,"level":4,"start":1362067200000,"name":"会员分类","assigs":[],"assess":"","depends":"","end":1362153599999},{"startIsMilestone":false,"workplanRelated":"","progress":"","status":"STATUS_ACTIVE","resourceDesc":"","resource":"","assessDesc":"","code":"13617197269421011978","endIsMilestone":false,"id":"tmp_fk1361719714398","duration":5,"level":1,"start":1362067200000,"name":"论坛","assigs":[],"assess":"","depends":"","end":1362671999999},{"startIsMilestone":false,"workplanRelated":"","progress":0,"status":"STATUS_SUSPENDED","resourceDesc":"范钢锋","assessDesc":"无","resource":"bluewind","code":"13617205581614024677","endIsMilestone":false,"id":"tmp_1361720521563","duration":5,"level":1,"start":1362672000000,"description":"","name":"网站与SAAS平台的整合","assigs":[],"assess":"0","depends":"21","end":1363276799999},{"startIsMilestone":false,"workplanRelated":"","progress":0,"status":"STATUS_SUSPENDED","resourceDesc":"范钢锋","assessDesc":"无","resource":"bluewind","code":"13617197639834438236","endIsMilestone":false,"id":"tmp_fk1361719730858","duration":1,"level":1,"start":1365955200000,"description":"","name":"试运行","assigs":[],"assess":"0","depends":"","end":1366041599999}],"canWriteOnParent":false}
  
  </textarea>
  <button onclick="loadGanttFromServer();">load</button>
    {"tasks":[
    {"id":-1,"name":"Gantt editor","code":"","level":0,"status":"STATUS_ACTIVE","start":1346623200000,"duration":16,"end":1348523999999,"startIsMilestone":true,"endIsMilestone":false,"assigs":[]},
    {"id":-2,"name":"coding","code":"","level":1,"status":"STATUS_ACTIVE","start":1346623200000,"duration":10,"end":1347659999999,"startIsMilestone":false,"endIsMilestone":false,"assigs":[],"description":"","progress":0},
    {"id":-3,"name":"gant part","code":"","level":2,"status":"STATUS_ACTIVE","start":1346623200000,"duration":2,"end":1346795999999,"startIsMilestone":false,"endIsMilestone":false,"assigs":[],"depends":""},
    {"id":-4,"name":"editor part","code":"","level":2,"status":"STATUS_SUSPENDED","start":1346796000000,"duration":4,"end":1347314399999,"startIsMilestone":false,"endIsMilestone":false,"assigs":[],"depends":"3"},
    {"id":-5,"name":"testing","code":"","level":1,"status":"STATUS_SUSPENDED","start":1347832800000,"duration":6,"end":1348523999999,"startIsMilestone":false,"endIsMilestone":false,"assigs":[],"depends":"2:5","description":"","progress":0},
    {"id":-6,"name":"test on safari","code":"","level":2,"status":"STATUS_SUSPENDED","start":1347832800000,"duration":2,"end":1348005599999,"startIsMilestone":false,"endIsMilestone":false,"assigs":[],"depends":""},
    {"id":-7,"name":"test on ie","code":"","level":2,"status":"STATUS_SUSPENDED","start":1348005600000,"duration":3,"end":1348264799999,"startIsMilestone":false,"endIsMilestone":false,"assigs":[],"depends":"6"},
    {"id":-8,"name":"test on chrome","code":"","level":2,"status":"STATUS_SUSPENDED","start":1348005600000,"duration":2,"end":1348178399999,"startIsMilestone":false,"endIsMilestone":false,"assigs":[],"depends":"6"}
    ],"selectedRow":0,"deletedTaskIds":[],"canWrite":true,"canWriteOnParent":false }
</div>

<style>
  .resEdit {
    padding: 15px;
  }

  .resLine {
    width: 95%;
    padding: 3px;
    margin: 5px;
    border: 1px solid #d0d0d0;
  }

  body {
    overflow: hidden;
  }
</style>

<form id="gimmeBack" style="display:none;" action="../gimmeBack.jsp" method="post" target="_blank"><input type="hidden" name="prj" id="gimBaPrj"></form>

<script type="text/javascript">

var ge;  //this is the hugly but very friendly global var for the gantt editor
$(function() {

  //load templates
  $("#ganttemplates").loadTemplates();

  // here starts gantt initialization
  ge = new GanttMaster();
  var workSpace = $("#workSpace");
  workSpace.css({width:$(window).width() - 20,height:$(window).height() - 100});
  ge.init(workSpace);

  //inject some buttons (for this demo only)
  $(".ganttButtonBar div").append("<button onclick='clearGantt();' class='button'>清空</button>")
          .append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
          .append("<button onclick='openResourceEditor();' class='button'>编辑资源</button>")
          .append("<button onclick='getFile();' class='button'>导出</button>");
  $(".ganttButtonBar h1").html("");//<img src='twGanttSmall.png'>");
  $(".ganttButtonBar div").addClass('buttons');
  //overwrite with localized ones
  loadI18n();

  //simulate a data load from a server.
  loadGanttFromServer();


  //fill default Teamwork roles if any
  if (!ge.roles || ge.roles.length == 0) {
    setRoles();
  }

  //fill default Resources roles if any
  if (!ge.resources || ge.resources.length == 0) {
    setResource();
  }


  /*/debug time scale
  $(".splitBox2").mousemove(function(e){
    var x=e.clientX-$(this).offset().left;
    var mill=Math.round(x/(ge.gantt.fx) + ge.gantt.startMillis)
    $("#ndo").html(x+" "+new Date(mill))
  });*/

});


function loadGanttFromServer(taskId, callback) {

  //this is a simulation: load data from the local storage if you have already played with the demo or a textarea with starting demo data
  loadFromLocalStorage();

  //this is the real implementation
  /*//var taskId = $("#taskSelector").val();
   var prof = new Profiler("loadServerSide");
   prof.reset();

   $.getJSON("ganttAjaxController.jsp", {CM:"LOADPROJECT",taskId:taskId}, function(response) {
   //console.debug(response);
   if (response.ok) {
   prof.stop();
   ge.loadProject(response.project);
   ge.checkpoint(); //empty the undo stack
   if (typeof(callback)=="function")
   callback(response);
   }else {
   jsonErrorHandling(response);
   }
   });*/
}


function saveGanttOnServer() {

  //this is a simulation: save data to the local storage or to the textarea
  saveInLocalStorage();


  /*var prj = ge.saveProject();
   delete prj.resources;
   delete prj.roles;
   var prof = new Profiler("saveServerSide");
   prof.reset();

   if (ge.deletedTaskIds.length>0){
   if (!confirm("TASK_THAT_WILL_BE_REMOVED\n"+ge.deletedTaskIds.length))
   return;
   }

   $.ajax("ganttAjaxController.jsp", {
   dataType:"json",
   data: {CM:"SVPROJECT",prj:JSON.stringify(prj)},
   type:"POST",

   success: function(response) {
   if (response.ok) {
   prof.stop();
   if (response.project){
   ge.loadProject(response.project); //must reload as "tmp_" ids are now the good ones
   } else {
   ge.reset();
   }
   } else {
   var errMsg="Errors saving project\n";
   if (response.message)
   errMsg=errMsg+response.message+"\n";

   for (var i=0;i<response.errorMessages.length;i++){
   errMsg=errMsg+response.errorMessages[i]+"\n";
   }
   alert(errMsg);
   }
   }

   });*/
}


//-------------------------------------------  Create some demo data ------------------------------------------------------
function setRoles() {
  ge.roles = [
    {
      id:"tmp_1",
      name:"Project Manager"
    },
    {
      id:"tmp_2",
      name:"Worker"
    },
    {
      id:"tmp_3",
      name:"Stakeholder/Customer"
    }
  ];
}

function setResource() {
  var res = [];
  for (var i = 1; i <= 10; i++) {
    res.push({id:"tmp_" + i,name:"Resource " + i});
  }
  ge.resources = res;
}


function clearGantt() {
  ge.reset();
}

function loadI18n() {
  GanttMaster.messages = {
    "CHANGE_OUT_OF_SCOPE":"NO_RIGHTS_FOR_UPDATE_PARENTS_OUT_OF_EDITOR_SCOPE",
    "START_IS_MILESTONE":"START_IS_MILESTONE",
    "END_IS_MILESTONE":"END_IS_MILESTONE",
    "TASK_HAS_CONSTRAINTS":"TASK_HAS_CONSTRAINTS",
    "GANTT_ERROR_DEPENDS_ON_OPEN_TASK":"GANTT_ERROR_DEPENDS_ON_OPEN_TASK",
    "GANTT_ERROR_DESCENDANT_OF_CLOSED_TASK":"GANTT_ERROR_DESCENDANT_OF_CLOSED_TASK",
    "TASK_HAS_EXTERNAL_DEPS":"TASK_HAS_EXTERNAL_DEPS",
    "GANNT_ERROR_LOADING_DATA_TASK_REMOVED":"GANNT_ERROR_LOADING_DATA_TASK_REMOVED",
    "ERROR_SETTING_DATES":"ERROR_SETTING_DATES",
    "CIRCULAR_REFERENCE":"CIRCULAR_REFERENCE",
    "CANNOT_DEPENDS_ON_ANCESTORS":"CANNOT_DEPENDS_ON_ANCESTORS",
    "CANNOT_DEPENDS_ON_DESCENDANTS":"CANNOT_DEPENDS_ON_DESCENDANTS",
    "INVALID_DATE_FORMAT":"日期格式非法",//"INVALID_DATE_FORMAT",
    "TASK_MOVE_INCONSISTENT_LEVEL":"TASK_MOVE_INCONSISTENT_LEVEL",

    "GANT_QUARTER_SHORT":"trim.",
    "GANT_SEMESTER_SHORT":"sem."
  };
}


//-------------------------------------------  Open a black popup for managing resources. This is only an axample of implementation (usually resources come from server) ------------------------------------------------------
function openResourceEditor() {
  var editor = $("<div>");
  editor.append("<h2>Resource editor</h2>");
  editor.addClass("resEdit");

  for (var i in ge.resources) {
    var res = ge.resources[i];
    var inp = $("<input type='text'>").attr("pos", i).addClass("resLine").val(res.name);
    editor.append(inp).append("<br>");
  }

  var sv = $("<div>save</div>").css("float", "right").addClass("button").click(function() {
    $(this).closest(".resEdit").find("input").each(function() {
      var el = $(this);
      var pos = el.attr("pos");
      ge.resources[pos].name = el.val();
    });
    ge.editor.redraw();
    closeBlackPopup();
  });
  editor.append(sv);

  var ndo = createBlackPage(800, 500).append(editor);
}

//-------------------------------------------  Get project file as JSON (used for migrate project from gantt to Teamwork) ------------------------------------------------------
function getFile() {
  $("#gimBaPrj").val(JSON.stringify(ge.saveProject()));
  $("#gimmeBack").submit();
  $("#gimBaPrj").val("");

  /*  var uriContent = "data:text/html;charset=utf-8," + encodeURIComponent(JSON.stringify(prj));
   console.debug(uriContent);
   neww=window.open(uriContent,"dl");*/
}


//-------------------------------------------  LOCAL STORAGE MANAGEMENT (for this demo only) ------------------------------------------------------
Storage.prototype.setObject = function(key, value) {
  this.setItem(key, JSON.stringify(value));
};


Storage.prototype.getObject = function(key) {
  return this.getItem(key) && JSON.parse(this.getItem(key));
};


function loadFromLocalStorage() {
  var ret;
  if (false && localStorage) {
    if (localStorage.getObject("teamworkGantDemo")) {
      ret = localStorage.getObject("teamworkGantDemo");
    }
  } else {
    $("#taZone").show();
  }
  if (!ret || !ret.tasks || ret.tasks.length == 0)
    ret = JSON.parse($("#ta").val());
  ge.loadProject(ret);
  ge.checkpoint(); //empty the undo stack
}


function saveInLocalStorage() {
  var prj = ge.saveProject();
  if (localStorage) {
    localStorage.setObject("teamworkGantDemo", prj);
  } else {
    $("#ta").val(JSON.stringify(prj));
  }
}


</script>


<div id="gantEditorTemplates" style="display:none;">
  <div class="__template__" type="GANTBUTTONS"><!--
  <div class="ganttButtonBar">
    <h1 style="float:left">task tree/gantt</h1>
    <div class="buttons">
    <button onclick="$('#workSpace').trigger('undo.gantt');" class="button textual" title="undo"><span class="teamworkIcon">&#39;</span></button>
    <button onclick="$('#workSpace').trigger('redo.gantt');" class="button textual" title="redo"><span class="teamworkIcon">&middot;</span></button>
    <span class="ganttButtonSeparator"></span>
    <button onclick="$('#workSpace').trigger('addAboveCurrentTask.gantt');" class="button textual" title="insert above"><span class="teamworkIcon">l</span></button>
    <button onclick="$('#workSpace').trigger('addBelowCurrentTask.gantt');" class="button textual" title="insert below"><span class="teamworkIcon">X</span></button>
    <span class="ganttButtonSeparator"></span>
    <button onclick="$('#workSpace').trigger('indentCurrentTask.gantt');" class="button textual" title="indent task"><span class="teamworkIcon">.</span></button>
    <button onclick="$('#workSpace').trigger('outdentCurrentTask.gantt');" class="button textual" title="unindent task"><span class="teamworkIcon">:</span></button>
    <span class="ganttButtonSeparator"></span>
    <button onclick="$('#workSpace').trigger('moveUpCurrentTask.gantt');" class="button textual" title="move up"><span class="teamworkIcon">k</span></button>
    <button onclick="$('#workSpace').trigger('moveDownCurrentTask.gantt');" class="button textual" title="move down"><span class="teamworkIcon">j</span></button>
    <span class="ganttButtonSeparator"></span>
    <button onclick="$('#workSpace').trigger('zoomMinus.gantt');" class="button textual" title="zoom out"><span class="teamworkIcon">)</span></button>
    <button onclick="$('#workSpace').trigger('zoomPlus.gantt');" class="button textual" title="zoom in"><span class="teamworkIcon">(</span></button>
    <span class="ganttButtonSeparator"></span>
    <button onclick="$('#workSpace').trigger('deleteCurrentTask.gantt');" class="button textual" title="delete"><span class="teamworkIcon">&cent;</span></button>
      &nbsp; &nbsp; &nbsp; &nbsp;
      <button onclick="saveGanttOnServer();" class="button first big" title="save">保存</button>
    </div></div>
  --></div>

  <div class="__template__" type="TASKSEDITHEAD"><!--
  <table class="gdfTable" cellspacing="0" cellpadding="0">
    <thead>
    <tr style="height:40px">
      <th class="gdfColHeader" style="width:35px;"></th>
      <th class="gdfColHeader" style="width:25px;"></th>
      <th class="gdfColHeader gdfResizable" style="width:30px;">编码</th>
      <th class="gdfColHeader gdfResizable" style="width:200px;">名称</th>
      <th class="gdfColHeader gdfResizable" style="width:80px;">开始</th>
      <th class="gdfColHeader gdfResizable" style="width:80px;">结束</th>
      <th class="gdfColHeader gdfResizable" style="width:50px;">工期</th>
      <th class="gdfColHeader gdfResizable" style="width:80px;">前置任务</th>
      <th class="gdfColHeader gdfResizable" style="width:200px;">办理</th>
    </tr>
    </thead>
  </table>
  --></div>

  <div class="__template__" type="TASKROW"><!--
  <tr taskId="(#=obj.id#)" class="taskEditRow" level="(#=level#)">
    <th class="gdfCell editTask" align="right" style="cursor:pointer;"><span class="taskRowIndex">(#=obj.getRow()+1#)</span> <span class="teamworkIcon" style="font-size:12px;" >e</span></th>
    <td class="gdfCell" align="center"><div class="taskStatus cvcColorSquare" status="(#=obj.status#)"></div></td>
    <td class="gdfCell"><input type="text" name="code" value="(#=obj.code?obj.code:''#)"></td>

    <td class="gdfCell indentCell" style="padding-left:(#=obj.level*10#)px;"><input type="text" name="name" value="(#=obj.name#)" style="(#=obj.level>0?'border-left:2px dotted orange':''#)"></td>

    <td class="gdfCell"><input type="text" name="start"  value="" class="date"></td>
    <td class="gdfCell"><input type="text" name="end" value="" class="date"></td>
    <td class="gdfCell"><input type="text" name="duration" value="(#=obj.duration#)"></td>
    <td class="gdfCell"><input type="text" name="depends" value="(#=obj.depends#)" (#=obj.hasExternalDep?"readonly":""#)></td>
    <td class="gdfCell taskAssigs">(#=obj.getAssigsString()#)</td>
  </tr>
  --></div>

  <div class="__template__" type="TASKEMPTYROW"><!--
  <tr class="taskEditRow emptyRow" >
    <th class="gdfCell" align="right"></th>
    <td class="gdfCell" align="center"></td>
    <td class="gdfCell"></td>
    <td class="gdfCell"></td>
    <td class="gdfCell"></td>
    <td class="gdfCell"></td>
    <td class="gdfCell"></td>
    <td class="gdfCell"></td>
    <td class="gdfCell"></td>
  </tr>
  --></div>

  <div class="__template__" type="TASKBAR"><!--
  <div class="taskBox" taskId="(#=obj.id#)" >
    <div class="layout (#=obj.hasExternalDep?'extDep':''#)">
      <div class="taskStatus" status="(#=obj.status#)"></div>
      <div class="taskProgress" style="width:(#=obj.progress>100?100:obj.progress#)%; background-color:(#=obj.progress>100?'red':'rgb(153,255,51);'#);"></div>
      <div class="milestone (#=obj.startIsMilestone?'active':''#)" ></div>

      <div class="taskLabel"></div>
      <div class="milestone end (#=obj.endIsMilestone?'active':''#)" ></div>
    </div>
  </div>
  --></div>


  <div class="__template__" type="CHANGE_STATUS"><!--
    <div class="taskStatusBox">
      <div class="taskStatus cvcColorSquare" status="STATUS_ACTIVE" title="active"></div>
      <div class="taskStatus cvcColorSquare" status="STATUS_DONE" title="completed"></div>
      <div class="taskStatus cvcColorSquare" status="STATUS_FAILED" title="failed"></div>
      <div class="taskStatus cvcColorSquare" status="STATUS_SUSPENDED" title="suspended"></div>
      <div class="taskStatus cvcColorSquare" status="STATUS_UNDEFINED" title="undefined"></div>
    </div>
  --></div>


  <div class="__template__" type="TASK_EDITOR"><!--
  <div class="ganttTaskEditor">
  <table width="100%">
    <tr>
      <td>
        <table cellpadding="5">
          <tr>
            <td><label for="code">编码</label><br><input type="text" name="code" id="code" value="" class="formElements"></td>
           </tr><tr>
            <td><label for="name">名称</label><br><input type="text" name="name" id="name" value=""  size="35" class="formElements"></td>
          </tr>
          <tr></tr>
            <td>
              <label for="description">描述</label><br>
              <textarea rows="5" cols="30" id="description" name="description" class="formElements"></textarea>
            </td>
          </tr>
        </table>
      </td>
      <td valign="top">
        <table cellpadding="5">
          <tr>
          <td colspan="2"><label for="status">状态</label><br><div id="status" class="taskStatus" status=""></div></td>
          <tr>
          <td colspan="2"><label for="progress">进度</label><br><input type="text" name="progress" id="progress" value="" size="3" class="formElements"></td>
          </tr>
          <tr>
          <td><label for="start">开始</label><br><input type="text" name="start" id="start"  value="" class="date" size="10" class="formElements"><input type="checkbox" id="startIsMilestone"> </td>
          <td rowspan="2" class="graph" style="padding-left:50px"><label for="duration">工期</label><br><input type="text" name="duration" id="duration" value=""  size="5" class="formElements"></td>
        </tr><tr>
          <td><label for="end">结束</label><br><input type="text" name="end" id="end" value="" class="date"  size="10" class="formElements"><input type="checkbox" id="endIsMilestone"></td>
        </table>
      </td>
    </tr>
    </table>

    <h2>任务</h2>
  <table  cellspacing="1" cellpadding="0" width="100%" id="assigsTable">
    <tr>
      <th style="width:100px;">name</th>
      <th style="width:70px;">role</th>
      <th style="width:30px;">est.wklg.</th>
      <th style="width:30px;" id="addAssig"><span class="teamworkIcon" style="cursor: pointer">+</span></th>
    </tr>
  </table>

  <div style="text-align: right; padding-top: 20px"><button id="saveButton" class="button big">save</button></div>
  </div>
  --></div>


  <div class="__template__" type="ASSIGNMENT_ROW"><!--
  <tr taskId="(#=obj.task.id#)" assigId="(#=obj.assig.id#)" class="assigEditRow" >
    <td ><select name="resourceId"  class="formElements" (#=obj.assig.id.indexOf("tmp_")==0?"":"disabled"#) ></select></td>
    <td ><select type="select" name="roleId"  class="formElements"></select></td>
    <td ><input type="text" name="effort" value="(#=getMillisInHoursMinutes(obj.assig.effort)#)" size="5" class="formElements"></td>
    <td align="center"><span class="teamworkIcon delAssig" style="cursor: pointer">d</span></td>
  </tr>
  --></div>

</div>
<script type="text/javascript">
  $.JST.loadDecorator("ASSIGNMENT_ROW", function(assigTr, taskAssig) {

    var resEl = assigTr.find("[name=resourceId]");
    for (var i in taskAssig.task.master.resources) {
      var res = taskAssig.task.master.resources[i];
      var opt = $("<option>");
      opt.val(res.id).html(res.name);
      if (taskAssig.assig.resourceId == res.id)
        opt.attr("selected", "true");
      resEl.append(opt);
    }


    var roleEl = assigTr.find("[name=roleId]");
    for (var i in taskAssig.task.master.roles) {
      var role = taskAssig.task.master.roles[i];
      var optr = $("<option>");
      optr.val(role.id).html(role.name);
      if (taskAssig.assig.roleId == role.id)
        optr.attr("selected", "true");
      roleEl.append(optr);
    }

    if (taskAssig.task.master.canWrite) {
      assigTr.find(".delAssig").click(function() {
        var tr = $(this).closest("[assigId]").fadeOut(200, function() {
          $(this).remove();
        });
      });
    }


  });
</script>



</body>
</html>